import { Component } from '@angular/core';
import {  NavController, NavParams, ModalController,LoadingController } from 'ionic-angular';
import {LoginPage} from '../login/login';
import {UserPage} from '../user/user';
import {Storage}from '@ionic/storage';
import { AppConfig } from '../../app/app.config';
import { BaseUI } from '../../common/baseui';

/**
 * Generated class for the MorePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@Component({
    selector: 'page-more',
    templateUrl: 'more.html'
})
export class MorePage extends BaseUI{
  headface:string;
  userData:any;
  
  public isLogin:boolean=false;
    constructor(public navCtrl: NavController,
       public navParams: NavParams, 
       public modalCtr: ModalController,
       public loading: LoadingController,
      public storage:Storage) {
        super()
      }

      ionViewDidEnter() {
        // console.log('ionViewDidLoad MorePage');
        this.loadUserPage()
    }
    showModal() {
        let modal = this.modalCtr.create(LoginPage);
        modal.present()
    }
    loadUserPage(){ 
      this.storage.get('userData').then((val)=>{  
          console.log(val)
        if(val!=null){
          // let loading=super.showLoading(this.loading,'加载中...')
          this.userData=val
          this.isLogin=true
          this.headface=AppConfig.appUrl()+'/'+val.member_avatar+'?'+(new Date()).valueOf();
          console.log(this.headface)
        }else{
         
        }
        console.log(this.isLogin)
      })
    } 
    goUser(){
      this.navCtrl.push(UserPage)
    }
}
